import React from 'react';
import {ActionConfig, ColumnsConfig} from "../../components/AntdCrud/index.tsx";
import CrudPage from "../../components/CrudPage/index.tsx";
import {EditLayout} from "../../components/AntdCrud/EditForm.tsx";
import {dateFormat} from "../../libs/utils.ts";


//字段配置
const columnsConfig: ColumnsConfig<any> = [
	{
		hidden: true,
		form: {
			type: "hidden"
		},
		dataIndex: "id",
		key: "id"
	},


	{
		supportSearch: true,
		form: {
			rules: [],
			type: "input"
		},
		dataIndex: "tokenValue",
		title: "TOKEN",
		key: "tokenValue"
	},

	{
		form: {
			type: "input"
		},
		dataIndex: "tokenDesc",
		title: "说明",
		key: "tokenDesc"
	},


	{
		form: {
			type: "hidden"
		},
		dataIndex: "created",
		title: "创建时间",
		key: "created",
		render: (value) => {
			return <span>{dateFormat(value,"YYYY-MM-DD HH:mm:ss")}</span>
		},
	}

];

//编辑页面设置
const editLayout = {
	labelLayout: "horizontal",
	labelWidth: 80,
	columnsCount: 1,
	openType: "modal"
} as EditLayout;


//操作列配置
const actionConfig = {
    addButtonEnable: true,
    detailButtonEnable: false,
    deleteButtonEnable: true,
    editButtonEnable: true,
    hidden: false,
    width: "200px",
    
} as ActionConfig<any>

export const SysToken: React.FC = () => {
    return (
        <CrudPage columnsConfig={columnsConfig} tableAlias="sysToken"
            actionConfig={actionConfig} editLayout={editLayout}/>
    )
};

export default {
    path: "/sys/sysToken",
    element:  SysToken
};
